﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ibba.agil.core.common;
using ibba.agil.core;

namespace ibba.agil.data.data
{
    public class tbagi007IpiLayoCamoKey : IDataKey
    {
        public enum enTipoConsulta
        {
            Todos = 0,
            FiltroLayou = 1
        }

        public enTipoConsulta TipoConsulta { get; set; }

        public int idtIpiCamo { get; set; }
    
    }

    public class tbagi007IpiLayoCamo_COL : CollectionData<tbagi007IpiLayoCamoKey, tbagi007IpiLayoCamo_ENT>
    {
        private manager.tbagi007IpiLayoCamo_COM _manager;
        private Criteria<CriteriaInfo, object> _pesquisa;

        public tbagi007IpiLayoCamo_COL()
        {
            _manager = new manager.tbagi007IpiLayoCamo_COM();
        }

        public override List<tbagi007IpiLayoCamo_ENT> Find(tbagi007IpiLayoCamoKey key)
        {
            #region Implementacao do Criterio de Pesquisa

            _pesquisa = new Criteria<CriteriaInfo, object>(new tbagi007IpiLayoCamo_ENT());

            switch (key.TipoConsulta)
            {
                case tbagi007IpiLayoCamoKey.enTipoConsulta.FiltroLayou:
                    _pesquisa.Add(new CriteriaInfo()
                    {
                        LikePattern = LikePattern.Both,
                        LogicalType = LogicalOperator.AND,
                        NameProperty = "idtIpiLayo",
                        SearchType = LogicalComparator.EQUAL
                    }, key.idtIpiCamo);
                    break;
                default:
                    break;
            }

            #endregion

            return _manager.Where(CriteriaFind);
        }

        protected override Criteria<CriteriaInfo, object> CriteriaFind()
        {
            return _pesquisa;
        }
    }
}
